import React from 'react'

import { useSelector, useDispatch } from 'dva'
import { Button } from 'antd'

import { history } from 'umi'

const Header: React.FC = () => {

    const adminname = useSelector((state: { admin: any }) => state.admin.adminname)

    const dis = useDispatch()

    return (
        <div>
            {
                adminname ? (<p>
                    欢迎 {adminname}
                    &#x3000;
                    <Button onClick={() => {
                        localStorage.clear()
                        history.push('/login')
                    }}> 退出登录 </Button>
                </p>) : (<p>
                    <Button onClick={() => {
                        history.push('/login')
                    }}> 请登录 </Button>
                </p>)
            }
        </div>
    )
}
export default Header